package cn.funeralobjects.upms.extension.mapping;

import cn.funeralobjects.upms.api.ApiApi;
import cn.funeralobjects.upms.extension.model.HandlerMethodMapping;
import cn.funeralobjects.upms.model.Api;
import lombok.Getter;

import java.util.List;
import java.util.function.Function;

/**
 * 用于UPMS注册的Api的映射器
 *
 * @author FuneralObjects
 * Create date: 2020/5/3 5:41 PM
 */
public class RegisterApiHandlerMapping extends BaseApiHandleMapping {

    /**
     * api接口
     */
    @Getter
    private final ApiApi apiApi;

    public RegisterApiHandlerMapping(ApiApi apiApi, String scope, Function<HandlerMethodMapping, String> createNameFun) {
        super(scope, createNameFun);
        this.apiApi = apiApi;
    }

    /**
     * @param apis 初始化的提取的API接口集合
     */
    @Override
    protected void handlerApiInitialized(List<Api> apis) {
        apiApi.addOrUpdateInBatch(apis).subscribe();
    }


}
